/*
package com.example.excel;

import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.client.utils.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import com.deepoove.poi.data.DocxRenderData;
import com.deepoove.poi.data.PictureRenderData;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.spk.se.MainApplication;
import com.spk.se.pa.entity.ProBase;
import com.spk.se.rpt.export.util.PoiTlExportUtil;
import com.spk.se.rpt.export.util.ProjectCodeRenderPolicy;
import com.spk.se.rpt.export.util.SymbolRenderData;
import com.spk.se.rpt.yfzd.entity.ProYfzdRpt;
import com.spk.se.rpt.yfzd.entity.ProYfzdRptAbroad;
import com.spk.se.rpt.yfzd.entity.ProYfzdRptLeader;
import com.spk.se.rpt.yfzd.export.AbroadTableRenderPolicy;
import com.spk.se.rpt.yfzd.service.ProYfzdRptBookService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptCmajobService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptConteduService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptEdureformService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptGuideService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptHltalentService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptIndexService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptLabService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptLabequService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptOrgsService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptPaperService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptPatentService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptProjectsService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptRewardService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptSystemService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptTechlevelService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptTechpaperService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptWorkloadService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptWorkshopService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptWritingsService;
import com.spk.se.rpt.yfzd.service.ProYfzdRptYiiglejobService;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = MainApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("dev")
// @WebAppConfiguration 和webEnvironment（支持websocket）不能同时存在
public class ProYfzdRptExportTest {

	@Autowired
	private ProYfzdRptService proYfzdRptService;
	@Autowired
	private ProYfzdRptIndexService proYfzdRptIndexService;
	@Autowired
	private ProYfzdRptCmajobService proYfzdRptCmajobService;
	@Autowired
	private ProYfzdRptYiiglejobService proYfzdRptYiiglejobService;
	@Autowired
	private ProYfzdRptHltalentService proYfzdRptHltalentService;
	@Autowired
	private ProYfzdRptWorkloadService proYfzdRptWorkloadService;
	@Autowired
	private ProYfzdRptTechlevelService proYfzdRptTechlevelService;
	@Autowired
	private ProYfzdRptProjectsService proYfzdRptProjectsService;
	@Autowired
	private ProYfzdRptPaperService proYfzdRptPaperService;
	@Autowired
	private ProYfzdRptRewardService proYfzdRptRewardService;
	@Autowired
	private ProYfzdRptPatentService proYfzdRptPatentService;
	@Autowired
	private ProYfzdRptGuideService proYfzdRptGuideService;
	@Autowired
	private ProYfzdRptWritingsService proYfzdRptWritingsService;
	@Autowired
	private ProYfzdRptWorkshopService proYfzdRptWorkshopService;

	@Autowired
	private ProYfzdRptConteduService proYfzdRptConteduService;
	@Autowired
	private ProYfzdRptEdureformService proYfzdRptEdureformService;
	@Autowired
	private ProYfzdRptTechpaperService proYfzdRptTechpaperService;
	@Autowired
	private ProYfzdRptBookService proYfzdRptBookService;

	@Autowired
	private ProYfzdRptLabService proYfzdRptLabService;
	@Autowired
	private ProYfzdRptLabequService proYfzdRptLabequService;
	@Autowired
	private ProYfzdRptSystemService proYfzdRptSystemService;
	@Autowired
	private ProYfzdRptOrgsService proYfzdRptOrgsService;
	
	@Autowired
	Environment env;
	
	public Map dataMap = new HashMap();
	
	public List<PictureRenderData> imgList = new ArrayList<PictureRenderData>();
	
	public List<String> wordList = new ArrayList<String>();

	@Test
	*/
/**
	 * 扬帆重点申报书，部分信息导出word
	 *//*

	public void testExportRpt() throws JsonParseException, JsonMappingException, IOException {
		
		//模版文件
		String templateFile = ProYfzdRptExportTest.class.getResource("附件1：北京市医院管理局重点医学专业发展计划申报书.docx").getPath();
		templateFile = URLDecoder.decode(templateFile, "utf-8");
		System.out.println("templateFile=" + templateFile);
		
		//目标生成文件
		String destFile = ProYfzdRptExportTest.class.getResource("").getPath()+"扬帆重点申报书导出_"+DateUtils.formatDate(new Date(),"yyyyMMdd")+".docx";
		System.out.println("destFile=" + destFile);
		
		*/
/************
		 * 基础数据准备 *
		 ************//*

		String rptId = "0b85ffa9-1c87-4379-b936-be24cdae6e75";
		// 申报书基本信息
		ProYfzdRpt rpt = proYfzdRptService.queryYfzdRptById(rptId);
		
		*/
/****************
		 * JSON类型数据处理 *
		 ****************//*

		//String devSts = rpt.getDevStatus();
		//${leader.extMap.devStatus}
		String devSts = "{\r\n" + 
				"	\"devStatus\": \"专业发展现状\",\r\n" + 
				"	\"mainDirection\": \"选择的主攻方向\",\r\n" + 
				"	\"workBasic\": \"目前具备的工作基础\",\r\n" + 
				"	\"notEnough\": \"尚存不足\",\r\n" + 
				"	\"otherInfo\": \"其他补充信息\"\r\n" + 
				"}\r\n" + 
				"";
		ObjectMapper mapper = new ObjectMapper();
		Map devStsMap = mapper.readValue(devSts,Map.class);
		rpt.getTails().putAll(devStsMap);
		//项目基本信息
		ProBase base = (ProBase) rpt.get("proBase");
		//项目编号
		base.setProjectCode("YFZDLCYX12");
		*/
/****************
		 * 复选框类别数据处理 *
		 ****************//*

		//复选框处理：项目类别
		String xmlb = base.getProjectClassify();
		base.set("xmlb_zdpy", "yfzd_zdpy".equals(xmlb)?new SymbolRenderData(SymbolRenderData.CHECKED_CHECKBOX):new SymbolRenderData(SymbolRenderData.CHECKBOX));
		base.set("xmlb_zdfc", "yfzd_zdfc".equals(xmlb)?new SymbolRenderData(SymbolRenderData.CHECKED_CHECKBOX):new SymbolRenderData(SymbolRenderData.CHECKBOX));
		*/
/****************
		 * 单选框类别数据处理 *
		 ****************//*

		//单选框测试
		//base.set("radio", new SymbolRenderData(SymbolRenderData.RADIO));
		//base.set("radio1", new SymbolRenderData(SymbolRenderData.CHECKED_RADIO));
		//负责人信息
		ProYfzdRptLeader proYfzdRptLeader = (ProYfzdRptLeader) rpt.get("proYfzdRptLeader");
		//需要单独处理博士研究生的聘任时间
		proYfzdRptLeader.set("prsj_year", "2017");
		proYfzdRptLeader.set("prsj_month", "12");
		
		*/
/**************************************
		 * HTML类型数据处理，解析html中的图片、table等 *
		 **************************************//*

		//业绩信息
		String performance_Word = PoiTlExportUtil.processHtmlContent(proYfzdRptLeader.getPerformance(), imgList, wordList);
		proYfzdRptLeader.set("performance_Word", new DocxRenderData(new File(performance_Word),null));
		//与历史信息不同点
		String diffrecent_Word = PoiTlExportUtil.processHtmlContent(proYfzdRptLeader.getDiffrecent(), imgList, wordList);
		proYfzdRptLeader.set("diffrecent_Word", new DocxRenderData(new File(diffrecent_Word),null));
		
		//科研方向及特色
		List kyList = new ArrayList();
		
		//国外学习研修信息
		ProYfzdRpt yfzdRpt =  proYfzdRptService.queryYfzdRptLeaderById(rptId);
		List<ProYfzdRptAbroad> proYfzdRptAbroadList = (List<ProYfzdRptAbroad>)yfzdRpt.get("proYfzdRptAbroad");
		
		//一个测试图片
		String picFile = ProYfzdRptExportTest.class.getResource("pic.jpg").getPath();
		
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		
		*/
/****************************************
		 * 数据统一存放的dataMap中，在模版中使用key值取值 *
		 ****************************************//*

		//存放数据
		dataMap.put("projectCodeTable", base.getProjectCode());
		dataMap.put("abroadTable", proYfzdRptAbroadList);
		dataMap.put("base", base);
		dataMap.put("rpt", rpt);
		dataMap.put("leader", proYfzdRptLeader);
		dataMap.put("curYear",cal.get(Calendar.YEAR));
		dataMap.put("curMonth", cal.get(Calendar.MONTH));
		dataMap.put("curDay", cal.get(Calendar.DAY_OF_MONTH));
		*/
/**********************
		 * 单独的图片类型数据处理 *
		 **********************//*

		//宽度*高度：150*210
		dataMap.put("pic", new PictureRenderData(130,180,picFile));
		
		*/
/**********************
		 * 自定义渲染策略和规则配置    *
		 **********************//*

		//自定义模版策略配置
		Map customPolicyMap = new HashMap();
		*/
/****************
		 * 项目编号的特殊处理*
		 ****************//*

		//项目编号特殊处理
		customPolicyMap.put("projectCodeTable", new ProjectCodeRenderPolicy());
		*/
/**********************
		 * word原生表格类型数据处理 *
		 **********************//*

		//国外学习研修表格
		customPolicyMap.put("abroadTable", new AbroadTableRenderPolicy(11 + kyList.size()));
		
		*/
/***************************
		 * 把数据渲染到模版并生成word文件   *
		 ***************************//*

		//渲染模版
		PoiTlExportUtil.renderTemplate(customPolicyMap, dataMap, templateFile, destFile);
		
		*/
/***************************
		 * 对html中包含的图片做单独渲染   *
		 ***************************//*

		for(PictureRenderData data : imgList) {
			String imgId = PoiTlExportUtil.getImgIdFromPath(data.getPath(), null);
			dataMap.put(imgId,data);
		}
		//把第一次渲染生成的文件当作模版再次渲染
		PoiTlExportUtil.renderTemplate(customPolicyMap, dataMap, destFile, destFile);
		
		*/
/*********************
		 * 清理过程中产生的临时文件  *
		 *********************//*

		for(String wordFile : wordList) {
			new File(wordFile).deleteOnExit();
		}
	}
	
}
*/
